 
import { ABaseDecision } from "GameLoop/DecisionMaking/BaseDecision";
import { MainStrategy } from "GameLoop/WorldState/EntityManager/CreateStrategy/MainStrategy";
import { getRoleConfig } from "utils/constants/bodyconstant";
import { priority } from "utils/constants/definetypes";
import { BodyEfficiency } from "utils/creep/bodyEfficiency";
import { TaskHelper } from "utils/task/TaskHelper";

/**
 * 预定任务决策
 */
export class ReserveDecision< T extends "creep"="creep"> extends ABaseDecision<T>
{
   
    public isExpired(event: NormalEvent, region: string): boolean 
    {
        const taskid =  `${event.room}_reserve`;
        const room = Game.rooms[event.region];
        const task = room.findTaskById(taskid,"creep");
        if(task)
        {
            return false;
        }
        return true;
    }
    public makeTask(event: NormalEvent, region: string): IDecisionCode<T>|false
    {
        
        const room = Game.rooms[event.region] as Required<Room>;
        
        const task:ITaskDeclare["creep"]={
            id: `${event.room}_reserve`,
            priority:priority.E,
            ttl:5000,
            type:"creep",
            data:{
                type:"claim",
                arg:{
                    room:event.room,
                    action:"reserve",
                },
                room:event.room,
                creeps:[],
                body:{},
                income:-1,
                cost:TaskHelper.getTaskPathCost(room.name,event.room),
                required:[
                    [["claimer"],1,1]
                ]
            },
            shard: 1,
        }
        const code:IDecisionCode<T>={
            region:event.region,
            isunique:false,
            task:[task],
        }
        return code
    }
    
}